package com.ruoyi.train.controller;

import java.util.List;



import com.ruoyi.train.domain.Vo.CertApplicationVo;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.ruoyi.train.domain.CertApplication;
import com.ruoyi.train.service.ICertApplicationService;

/**
 * 办证申请Controller
 * 
 * @author wusihao
 * @date 2023-04-18
 */
@RestController
@RequestMapping("/certificate/submitcertificate")
public class CertApplicationController extends BaseController
{
    @Autowired
    private ICertApplicationService certApplicationService;

    /**
     * 查询办证申请列表
     */
    @GetMapping("/list")
    public TableDataInfo list(CertApplication certApplication)
    {
        startPage();
        List<CertApplicationVo> list = certApplicationService.selectCertApplicationList(certApplication);
        return getDataTable(list);
    }

    /**
     * 获取办证申请详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(certApplicationService.selectCertApplicationById(id));
    }

    /**
     * 新增办证申请
     */
    @Log(title = "办证申请", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CertApplication certApplication)
    {
        return toAjax(certApplicationService.insertCertApplication(certApplication));
    }

    /**
     * 修改办证申请
     */
    @Log(title = "办证申请", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CertApplication certApplication)
    {
        return toAjax(certApplicationService.updateCertApplication(certApplication));
    }

    /**
     * 删除办证申请
     */
    @Log(title = "办证申请", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(certApplicationService.deleteCertApplicationByIds(ids));
    }

    /**
     * 通过办证申请表id查询办证申请表
     */
    @GetMapping("/getCertApplication/{certApplicationId}")
    public AjaxResult getCertApplication(@PathVariable Long certApplicationId)
    {
        return success(certApplicationService.getCertApplicationById(certApplicationId));
    }

    /**
     * 培训机构提交办证申请表
     */
    @GetMapping("/peixunjigousubmitCertApplication/{certApplicationId}")
    public AjaxResult peixunjigousubmitCertApplication(@PathVariable Long certApplicationId)
    {
        return success(certApplicationService.peixunjigousubmittezhongCertApplication(certApplicationId));
    }
}
